package leetcode;

/**
 * @Classname MaxDepth_104
 * @Author happytaohaha
 * @Date 2020/3/10
 * @Description 二叉树的最大深度  DFS 子节点高度加1
 */
public class MaxDepth_0104 {

    public static int maxDepth(TreeNode root) {
        if(root==null){
            return 0;
        }else{
            int leftHeight = maxDepth(root.left);
            int rightHeight = maxDepth(root.right);
            return Math.max(leftHeight,rightHeight)+1;
        }
    }

}
